import http from '@/api/request'
import type { DocForm, DocFormApproval, DocFormComment, OaWorkflowStatus } from '@/types/workflow'

/**
 * 获取审核意见
 * @param formId 
 */
export const getApprovals =  async (formId:any):Promise<DocFormApproval[]>=>{
    const result =  await http.get<DocFormApproval[]>('/form/getApprovals',{
        formId
    })

    if(result.data){
        return result.data;
    }else{
        return []
    }
}


/**
 * 获取docform
 * @param formId 
 */
export const getDocForm =  async (fid:any)=>{
    const result =  await http.get<DocForm,OaWorkflowStatus>('/form/get',{
        fid
    })
    return result;
}


export const addRemark = async (formId:any,content:string)=>{
    const result = await http.post('/form/addRemark',{
        docFormId:formId,
        content
    })
}

/**
 * 获取补充批注
 * @param formid 获取补充批注
 */
export const getComments = async(fid:any)=>{
    const result = await http.get<DocFormComment[]>('/form/getComments',{
        fid
    })
    return result.data;
}


/**
 *  取消收藏
 */
export const removeFavo = async(id:any)=>{
    const result = await http.post<string>('/form/removeFavor',{
        id
    })
    return result.data;
}


/**
 *  添加收藏
 */
export const addFavo = async(id:any)=>{
    const result = await http.post<string>('/form/addFavor',{
        id
    })
    return result.data;
}

export const isFavo = async(id:any)=>{
    const result = await http.get<boolean>('/form/isFavo',{
        formId:id
    })
    return result.data;
}

/**
 * 领导参会
 */
export const meeting= async (id:any,meetingDateStr:string,leaders:string)=>{
    const result = await http.post<string>('/form/meeting',{
        id,
        meetingDateStr,
        meetingLeaders:leaders
    })
    return result;
}